﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Layouts/List.Master" AutoEventWireup="true" CodeBehind="ModuleList.aspx.cs" Inherits="Bingosoft.WebApp.Modules.SecurityConsole.Privilege.ModuleList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>模块信息列表</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
    <!-- 搜索框 -->
	<div class="search" style="margin-top:2px;">
        <web:search ID="GridSearch" GridViewId="SmartGridView1" runat="server">            
            <SearchConditionTemplate>                                       
                <table cellpadding="0" cellspacing="0" width="95%">
			        <tr>
                        <th>
                            模块名称：
                        </th>
	                    <td>
		                    <asp:TextBox ID="Name" name="Name" runat="server"></asp:TextBox>
	                    </td>                        
                    </tr>
                </table>
            </SearchConditionTemplate>                      
        </web:search>
    </div>

    <div class="datalist">
	    <!-- 标题头 -->
	    <h2 style="height:30px;">
			模块信息列表
	    </h2>
	    <!-- 工具栏 -->
	    <div class="toolbar"  style="height:30px;">
            <asp:LinkButton ID="btnAdd" runat="server"
                OnClientClick="return openEditor(this, 'Insert');" OnClick="SearchGrid">
                <span>
                    <img alt="" runat="server" id="img1" src="~/Images/icon_new.gif" style="border: 0px" />新建模块
                </span>
            </asp:LinkButton>
             <asp:LinkButton ID="btnDelete" runat="server"
                OnClientClick="return delModules();" OnClick="DelModules">
                <span>
                    <img id="Img2" alt="" runat="server" src="~/Images/ico_del.gif" style="border: 0px" />删除模块
                </span>
            </asp:LinkButton>
	    </div>
	    <div class="datagrid"  style="clear:left;">    
            <!--------------------------- List Area --------------------------->
            <web:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False"
                Width="100%" DataKeyNames="Id" DataSourceID="SmartDataSource1" PageSize="10">
                <Columns>            
                    <asp:CheckBoxField DataField="Id" ItemStyle-HorizontalAlign="Center" />  
                    <asp:BoundField DataField="Code" HeaderText="模块编码" SortExpression="Code" ItemStyle-HorizontalAlign="Left"/>  
                    <asp:BoundField DataField="Name" HeaderText="模块名称" SortExpression="Name" ItemStyle-HorizontalAlign="Left"/>
                    <asp:BoundField DataField="ParentName" HeaderText="上级模块" SortExpression="ParentName" ItemStyle-HorizontalAlign="Left"/>
                    <asp:BoundField DataField="Url" HeaderText="地址控件" SortExpression="Url" ItemStyle-HorizontalAlign="Left" />
            
                    <asp:TemplateField HeaderText="操作">
                        <ItemStyle HorizontalAlign="Center" />
                        <HeaderStyle Wrap="False" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <table width="46px">
                                <tr>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnEdit" runat="server" ToolTip="编辑"  _KeyId='<%#Eval("Id")%>'
                                            ImageUrl="~/Images/com/dg_edit.gif" CausesValidation="False" OnClientClick="return openEditor(this, 'Edit');" OnClick="RefreshGrid">
                                        </asp:ImageButton>
                                    </td>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnDelete" runat="server" ToolTip="删除" ImageUrl="~/Images/com/dg_del.gif" _KeyId='<%#Eval("Id")%>'
                                            CausesValidation="False" OnClientClick="return confirm('您确认要删除该模块吗?')" OnClick="DeleteModule">
                                        </asp:ImageButton>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                 <CheckBoxSettings Enabled="True" Position="0"/>
                <PagerSettings />
                <EditRowStyle HorizontalAlign="Center" />
            </web:SmartGridView>
    
            <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="privilege.module.list"
            DeleteCommand="privilege.module.delete"
             SelectCommandAutoPageWrap="true" DefaultSortExpression="Id DESC">       
            </web:SmartSqlDataSource>
        </div>
	</div>

      <script type="text/javascript">
          var moduleId = '<%=Request.Params["ParentId"] %>';
          var moduleName = '<%=Request.Params["ParentName"]%>';

          function openEditor(_this, action) {
              var url = "ModuleEdit.aspx";

              // FormViewMode : Insert/Edit/ReadOnly
              var params = { FormViewMode: action }
              if (action == "Insert") {
                  params.title = "模块新增";
                  params.ParentId = moduleId;
                  params.ParentName = moduleName;
              } else if (action == "Edit") {
                  params.title = "模块编辑";
                  params.Id = _this.attributes["_KeyId"].value;
                  params.ParentName = moduleName;
              }

              var returnValue = showCenterModalDialog(buildUrl(url, params), 550, 330, null);

              if (returnValue == "true") {
                  window.parent.reloadTree();
                  return true;
              }
              return false;
          }

          function delModules() {
              var oSmartGridView1 = document.getElementById("<%=SmartGridView1.ClientID%>");
              var sValues = oSmartGridView1.control.getCheckedValues(true);

              if (sValues && sValues.length > 0) {
                  if (window.confirm("您确认要删除所选的模块吗？")) {
                      return true;
                  }
              }

              return false;
          }    
    </script>
</asp:Content>
